package me.zhengjie.gas.mqtt.config;

import io.vertx.mqtt.MqttClientOptions;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * @author tsg
 * @version 1.0
 * @description: MqttClientProperties
 * @date 2022/4/28 10:13
 */
@Data
@Component
@ConfigurationProperties(prefix = "mqtt.client")
public class MqttClientProperties {

    private String clientId;

    // 地址
    private String host = MqttClientOptions.DEFAULT_HOST;
    // 端口号
    private Integer port = MqttClientOptions.DEFAULT_PORT;
    // 登录用户
    private String username;
    // 登录密码
    private String password;

    // 连接超时时间(秒)
    private Integer connectTimeout;

    // 等待mqtt回应的超时时间
    private Integer ackTimeout =MqttClientOptions.DEFAULT_ACK_TIMEOUT;

    private boolean autoGeneratedClientId = true;

    private boolean autoKeepAlive = true;

    private boolean cleanSession ;

    private boolean willFlag ;

    private int willQoS;

    private boolean willRetain;

    private int keepAliveInterval = MqttClientOptions.DEFAULT_KEEP_ALIVE_INTERVAL;

    private int maxInflightQueue;

    private int maxMessageSize = MqttClientOptions.DEFAULT_MAX_MESSAGE_SIZE;

    private String willMessage;

    private String willTopic;

    // 连接池的配置
    private int minIdle = 3;

    private int maxTotal = 8;

    private int maxIdle = 8;

    private int maxWaitMillis = 6000;

    // 为true时borrowMaxWaitMillis才有作用
    private boolean blockWhenExhausted = true;

    // 设置成true才会调用工厂验证
    private boolean testOnBorrow = true;

    private boolean testOnReturn;

    private boolean testWhileIdle;

    private boolean jmxEnabled = false;

    private boolean fairness;

    private boolean maxWaitDuration;

    // 订阅的topic
    private String subscribeTopic;
    // 订阅的qos
    private int qosLevel;
}
